package com.sun.controller;

import com.sun.entity.User;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 接收xml请求的接⼝
 * RequestBody注解接收的参数是来自requestBody中的，即请求体；一般用于处理非Content-Type：application/x-www-form-urlencoded编码格式的数据，
 * 比如application/json、application/xml等类型的数据；
 * @author Administrator
 */
@Controller
public class UserController {

    @PostMapping(value = "/user",
        consumes = MediaType.APPLICATION_XML_VALUE,
        produces = MediaType.APPLICATION_XML_VALUE
    )
    @ResponseBody
    public User create(@RequestBody User user){
        user.setName("didispace.com : " + user.getName());
        user.setAge(user.getAge() + 100);
        return user;
    }
}
